﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
using System.Data.SqlClient;
using System.Data.Common;

public partial class InstanceList : System.Web.UI.Page
{
    Microsoft.Practices.EnterpriseLibrary.Data.Database db = DatabaseFactory.CreateDatabase("Application_Data");

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

        }        

        if (Request.QueryString["Where"].ToString() == "Monitored")
        {
            DataSet ds = db.ExecuteDataSet(CommandType.Text, "SELECT InstanceName,InstanceShortDescription,InstanceVersion FROM Instance Where DashboardActive = 1");

            this.gv.DataSource = ds;
            this.gv.DataBind();
        }
        else if (Request.QueryString["Where"].ToString() == "NOTMonitored")
        {
            DataSet ds = db.ExecuteDataSet(CommandType.Text, "SELECT InstanceName,InstanceShortDescription,InstanceVersion FROM Instance Where DashboardActive = 0");

            this.gv.DataSource = ds;
            this.gv.DataBind();
        }
        else if (Request.QueryString["Where"].ToString() == "Total")
        {
            DataSet ds = db.ExecuteDataSet(CommandType.Text, "SELECT InstanceName,InstanceShortDescription,InstanceVersion FROM Instance");

            this.gv.DataSource = ds;
            this.gv.DataBind();
        }
        else
        {
            DataSet ds = db.ExecuteDataSet(CommandType.Text, "SELECT InstanceName,InstanceShortDescription,InstanceVersion FROM Instance");

            this.gv.DataSource = ds;
            this.gv.DataBind();
        }

        this.lblResults.Text = "Results Found: " + this.gv.Rows.Count.ToString();
    }
}
